ConfigureDc
配置分散式时钟 (DC) 选项。分散式时钟允许从站循环与 KINGSTAR 循环同步,强烈建议任何运动应用程式皆需避免震动。
- Master Shift: the reference clock is the clock of the first slave on the EtherCAT network with the DC capability.
- 总线偏移:参照时钟为主站时钟。
语法
KsError ConfigureDc(
BOOL Active,
BOOL CheckStatus,
BOOL MasterShift,
int ReferenceIndex
);
参数
Active:设置 TRUE 以启用;FALSE 停止 DC 同步,预设为 TRUE。
CheckStatus:开启时启用 DC 抖动检查。同步完成后,装置会来到运作状态 (Op),此将会使开启过程慢约 15 秒,预设为 TRUE。
MasterShift:选择偏移模式,TRUE:主控装置偏移;FALSE:总线偏移,预设为 FALSE。
Bus Shift means that the EtherCAT slaves follow the master (computer) clock. Master Shift means the slaves and the master follow one of the slaves called "Reference Clock." 依预设,参考时钟会是总线上第一个支援 DC 的从站。
注意:从站时钟可能会比电脑时钟准确,因此主站偏移较为稳定,然而,主站偏移修改了电脑时钟的速度,此将影响电脑上所有的时间戳记,若电脑上同时有其他通讯协定,此将产生问题。
ReferenceIndex:选择参考时钟的装置。此参数为从站 ID,亦即装置的 EtherCAT ID,其对应于装置在 EtherCAT 循环中的位置 ,此 ID 从零开始,不受别名影响。
注意:尚未套用 ReferenceIndex。
回传值
如果此函式执行成功,会回传 errNoError
,否则会传回错误码。如需更多有关错误码的资讯,请参阅 KsError 清单。
备注
- 停用 DC 检查可减少 10 秒的启动时间,但即无法保证同步将在系统启动时准备就绪,当系统至运作模式 (Op) 后,时钟同步约需一分钟,因此建议维持 DC 启用状态。
- 在主站偏移下,从站较为稳定但主站较不稳定,从站偏移应仅在需要时使用。
- 此函式必须在 Create 后及 Start 前呼叫。
可用的 EtherCAT 状态
ecatOffline
范例
//////////////////////////////////////////////////////////////////
//
// This code snippet demonstrates how to use subsystem configuration
// and axis variable APIs to configure the setting before starting
// KINGSTAR subsystem.
//
//////////////////////////////////////////////////////////////////
// Variable declaration
KsError nRet = errNoError;
KsCommandStatus Command = { 0 };
SubsystemStatus Subsystem = { ecatOffline, ecatOffline, 0, 0, 0, {ecatOffline}, {ecatOffline}, {axisOffline} };
double featStatus = -1.0;
// Link to the KINGSTAR subsystem
nRet = Create(0, 0);
// Configure the subsystem settings
// Before enable the features, please check if the corresponding licenses are all enabled
// in the runtime environment.
nRet = ConfigureDc(TRUE, TRUE, TRUE, 0);
nRet = EnableAutoConfig(TRUE);
nRet = EnableAutoRepair(TRUE);
nRet = EnableAutoRestart(TRUE);
nRet = EnableHotConnect(FALSE);
nRet = EnableRedundancy(FALSE);
nRet = EnableServerLog(FALSE);
nRet = SetCycleTime(cycle500);
// Configure the axis variables
// Before enabling variables in the program, you should:
// 1. Read the user manual to check if the variables are available in the device.
// 2. Check if the corresponding variables are put in the PDO list in ESI import tool.
// For further details, see Help System >> KINGSTAR ESI Import Tool >> Tabs >> PDO.
nRet = EnableActualCurrent(TRUE);
nRet = EnableActualTorque(TRUE);
nRet = EnableActualVelocity(TRUE);
nRet = EnableAxisInput(TRUE);
nRet = EnableAxisOutput(FALSE);
nRet = EnableFollowingError(TRUE);
nRet = EnableMaxCurrent(TRUE);
nRet = EnableMaxTorque(TRUE);
nRet = EnableProfilePosition(FALSE);
nRet = EnableSecondEncoder(FALSE);
nRet = EnableSynchronizedControlMode(TRUE);
nRet = EnableTorqueOffset(FALSE);
nRet = EnableTouchProbe(FALSE);
nRet = SetAxisAccessMode(accessPos); // Refer to KsAccessMode page for detailed introduction
// Subsystem setting can be checked anytime after successfully calling Create().
// It is useful to check the feature status when you save the settings in a .kst file
// and start the subsystem via StartFromConfiguration().
nRet = GetFeatureStatus(KsFeature::featureCycleTime, &featStatus);
// Start the EtherCAT network
// You can only configure the setting before starting the subsystem
// If you need to modify the setting, call Stop() first.
Command = WaitForCommand(30, TRUE, Start());
使用需求
RT | Win32 | |
---|---|---|
最低支援版本 | 4.0 | 4.0 |
标头档 | ksapi.h | ksapi.h |
程式库 | KsApi_Rtss.lib | KsApi.lib |
参见